package com.linzm.creationaltype.prototype05.factory;

import com.linzm.creationaltype.prototype05.enums.ShapeTypeEnum;
import com.linzm.creationaltype.prototype05.shape.Shape;

/**
 * @Author zimingl
 * @Date 2023/4/15 21:34
 * @Description: ShapeFactory
 */
public class ShapeFactory {
    public Shape getShape(String type) throws Exception {
        ShapeTypeEnum shapeTypeEnum = ShapeTypeEnum.valueOf(type);
        Class<?> clazz = shapeTypeEnum.getClazz();
        return (Shape) clazz.newInstance();
    }
}
